<template>
	<view class="inspectContent">
		<commonNavBar title="抽检不合格主体"  :showSearch="true"  @search="open" ></commonNavBar>  
		<view class="centre">
			<z-paging ref="paging" autowire-list-name="inspectList"  autowire-query-name="listData"  >
				<view class="li" v-for="(list, index) in inspectList" :key="index"  @tap="resultListActive(index)">
					<view class="float">{{ list.cyhj }}</view>
					<view class="h1">{{ index + 1 }}.{{ list.bcydwmc }}</view> 
					<view class="h2">样品名称:{{ list.ypmc }}</view>
					<view class="h2">业态:{{ list.spdl }}</view>
					<view class="h2">统一社会信用代码:{{ list.yyzzh }}</view>
					<view class="h2">抽检时间:{{ list.cjrq }}</view> 
				</view>
			</z-paging>
		<CommonSearchCompontVue  @seacharResult="seacharResult" :showSampleName="true" :showTime="true" :showSearchCompont="showSearchCompont"  ></CommonSearchCompontVue>
		</view>
		<!-- <view class="fixed">当前已搜索到{{ total }}条数据</view> -->
		<uni-popup ref="popup" type="bottom" :is-mask-click="false"   >
			<view class="popupContent"  :style="{maxHeight: (scrollHeight +100) + 'px'}">
				<view class="title">高级查询</view>
				<view class="ul"   :style="{maxHeight: scrollHeight + 'px'}">
					<view class="li">
						<view class="left">检查时间：</view>
						<view class="right">
							<view class="input-container" style="display: flex;flex-direction: row;justify-content: space-between;align-items: center">
							<input type="text" placeholder="请选择检查时间" :value="checkTimeStr"  @tap="showDate" :disabled="true"  :border="false"  style="font-size: 13px;margin-left: -10px;"
								  placeholder-style="color:#999999:font-size:13px"  />
							  <image v-if="checkTimeStr != ''" @tap="clearDate" src="/static/img/no.png" style="width: 14px;height: 14px;" ></image>
							</view> 
						</view>
					</view>
					<view class="li">
						<view class="left">生产经营主体：</view>
						<view class="right">
								<input type="text" placeholder="请输入生产经营主体名称" v-model="companyName"   :border="false"  style="font-size: 13px;margin-left: -10px;"
									  placeholder-style="color:#999999:font-size:13px" />
						</view>
					</view>
					<view class="li">
						<view class="left">经营地址：</view>
						<view class="right">
								<input type="text" placeholder="请输入经营地址" v-model="companyAddress"  style="font-size: 13px;margin-left: -10px;"  :border="false" 
									placeholder-style="color:#999999:font-size:13px"/>
						</view>
					</view> 
					<view class="li" >
						<view class="left">样品名称：</view>
						<view class="right">
								<input type="text" placeholder="请输入样品名称" v-model="sampleName"  style="font-size: 13px;margin-left: -10px;"  :border="false" 
									placeholder-style="color:#999999:font-size:13px"/>
						</view>
					</view> 
				</view>
				<view class="button">
					<button class="determine" @click="confirmBtn">确定</button>
					<button class="cancellation" @click="cancellation">取消</button>
				</view>
			</view>
		</uni-popup>
		<liu-calendar-date ref="calendar2" isRange  @checked='selectedDate'  ></liu-calendar-date>
	</view>
</template>

<script> 
		
	import commonNavBar from '@/components/CommonNavBar.vue';
	
	export default {
		components:{
			commonNavBar
		},
		data() {
			return {  
				checkTimeArr: [], 
				checkTimeStr: '', 
				sampleName: '',  
				companyAddress: '', 
				companyName: '', 
				scrollHeight: 0, 
				roteStatus: false, 
				tabIndex:0,
				showSearchCompont:false,
				inspectList: [], 
				total: 0, 
				searchParams:{ 
					pageNum:1,
					pageSize:10,
				}
			}
		},  
		onLoad() {
			
			this.scrollHeight = uni.getSystemInfoSync().screenHeight - 180
		},
		methods: {
			open() {   
				this.$refs.popup.open()
			},   
			seacharResult(e){
				//检索条件点击确定或者删除的时候在执行
				this.showSearchCompont =  false;
				if(e.search){
					this.searchParams = e;
					this.$refs.paging.reload();
				} 
			},
			
			showDate(){
				 this.$refs.calendar2.open()
			},
			goBack() {
				uni.navigateBack();
			}, 
			async listData(pageNo, pageSize) { 
				this.searchParams.pageNum = pageNo;
				this.searchParams.pageSize= pageSize;
				if(this.checkTimeArr != ''){
					this.searchParams.startTime= this.checkTimeArr[0];
					this.searchParams.endTime= this.checkTimeArr[1];
				} else {
					this.searchParams.startTime= '';
					this.searchParams.endTime= '';
				}
				this.searchParams.sampleName= this.sampleName; 
				this.searchParams.companyAddress= this.companyAddress;
				this.searchParams.companyName= this.companyName;  
				try { 
					const res = await uni.$api.spotCheckList(this.searchParams); 
					this.$refs.paging.complete(res.data.data);
				}  catch (error) { 
					 this.$refs.paging.complete(false);
				}
				
			}, 
			confirmBtn(){
				this.$refs.calendar2.close();
				 this.$refs.popup.close()
				this.$refs.paging.reload();
			}, 
			cancellation(){
				this.$refs.popup.close();
			}, 
			selectedDate(e){ 
				console.log(e)
				if(e.value.length == 0){
					uni.showToast({
						icon:'error',
						title: '未选择时间'
					})
					return;
				}
				if(e.value.length == 1){
					uni.showToast({
						icon:'error',
						title: '未正常选择时间段'
					})
					return;
				}
				this.checkTimeArr = e.value
				this.checkTimeStr = e.value[0] + '至' + e.value[1]
			},
			resultListActive(index){
				const that = this;
				//进入到查看检查结果详情
				uni.navigateTo({
					url: '/pages/spotCheck/spotInfo',
					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('loadSpotData',  that.inspectList[index] )
					}
				})
			}, 
			clearDate(){
				 this.checkTimeArr = []
				 this.checkTimeStr = ''
			},
			close() {
				this.$refs.popup.close()
			} 
		},
		watch: {
			
		},
	}
</script>

<style lang="scss">
	.inspectContent {
		background: #F9F9F9;
		height: calc(100vh - 195rpx);

		.upper {
			position: fixed;
			z-index: 1;
			top: 0;
			left: 0;
			width: 100%;

			.title {
				background: url('../../static/img/inspectBg.png');
				background-size: cover;
				width: 100%;
				height: 115rpx;
				line-height: 115rpx;
				position: relative;
				display: flex;
				justify-content: center;

				.arrow {
					position: absolute;
					left: 33rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 100rpx;
					height: 100rpx;
					 
					&::before {
						display: block;
						content: "";
						position: absolute;
						top: 50%;
						left: 0%;
						width: 20rpx;
						height: 20rpx;
						border-left: 1px solid #fff;
						border-top: 1px solid #fff;
						transform: translate(0%, -50%) rotate(-45deg);
					}
				}

				text {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					letter-spacing: 1px;
				}

				.screen {
					position: absolute;
					right: 30rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 35rpx;
					height: 33rpx; 
				}
				
				.routePlanning {
					position: absolute;
					right: 80rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 28rpx;
					height: 33rpx; 
				}
				
				.routePlanning2 {
					position: absolute;
					right: 120rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 28rpx;
					height: 33rpx;
				}
			}

			.step {
				display: flex;
				justify-content: space-around;
				height: 80rpx;
				line-height: 80rpx;
				background: #F9F9F9;

				view {
					position: relative;
					font-size: 25rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;

					&.active {
						color: #0552A9;

						&::before {
							display: block;
							content: "";
							position: absolute;
							left: 50%;
							bottom: 0%;
							transform: translate(-50%, 0%);
							width: 100rpx;
							height: 5rpx;
							background: #0552A9;
						}
					}
				}
			}
		}

		.centre {
			margin: 115rpx 0 0 0;
			padding: 0 17.5rpx;
			height: calc(100vh - 280rpx);
			overflow-x: hidden;
			
			.z-paging-content-fixed {
				padding: 115rpx 0 0 0;
			}

			.li {
				background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 100%);
				box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
				border-radius: 15rpx;
				padding: 30rpx 30rpx 15rpx 28rpx;
				position: relative;
				margin: 13rpx 20rpx 0;

				.float {
					position: absolute;
					top: 0;
					right: 0;
					// width: 97rpx;
					padding: 0 10rpx;
					height: 46rpx;
					line-height: 46rpx;
					background: linear-gradient(180deg, #5DA1FF 0%, #0054C9 100%);
					border-radius: 0rpx 11rpx 0rpx 11rpx;
					font-size: 18rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					text-align: center;
				}

				.h1 {
					font-size: 24rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 1;
					margin: 0 0 14rpx 0;
				}

				.h2 {
					font-size: 19rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					line-height: 1;
					margin: 12rpx auto;
				}

				.order {
					margin: 24rpx auto 0; 
					white-space: nowrap;
					overflow-x: auto; 
					
					.dd {
						width: 120rpx;
						height: 55rpx;
						border-radius: 9rpx;
						border: 1rpx solid #979797;
						font-size: 20rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 700;
						color: #A1A1A1; 
						position: relative;
						text-indent: -10rpx;
						display: inline-block;
						text-align: center; 
						border: 1px solid #F9A240;
						background: #F9A240;
						color: #fff;
						
						.dd1 { 
							display: flex;
							flex-direction: column;
							align-items: center;
							justify-content: center; 
							height: 55rpx;
						}

						 
	
						.triangle {
							width: 0;
							height: 0;
							border-top: 8rpx solid transparent;
							border-bottom: 8rpx solid transparent;
							border-left: 10rpx solid #A1A1A1;
							border-left: 10rpx solid #fff;
							position: absolute;
							top: 50%;
							right: 4rpx;
							transform: translate(-50%, -50%);
						}

						&+.dd {
							margin: 0 0 0 12rpx;
						}

						&.Active {
							border: 1px solid #00BE8C;
							background: #00BE8C;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.Expired  {
							border: 1px solid #f95e5a;
							background: #f95e5a;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.NotYetDue  {
							border: 1px solid #999999;
							background: #999999;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.special { 
							border: 1px solid #026DC6;
							background: #026DC6;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
					}
				}
			}
		}

		.fixed {
			display: none;
			position: fixed;
			left: 50%;
			bottom: 26rpx;
			transform: translate(-50%, 0);
			width: 100%;
			text-align: center;
			font-size: 18rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #A7A7A7;
		}

		.popupContent {
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 0 0;

			.uni-datetime-picker {
				width: 100%;
			}

			.title {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				background: url('../../static/img/popupTitle.png') no-repeat center center;
				background-size: cover;
				font-size: 25rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				text-indent: 45rpx;
			}

			.ul {

				.li {
					padding: 0 45rpx;
					margin: 0 auto;
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 68rpx;
					line-height: 68rpx;
					border-bottom: 1px solid #d6d6d6;
						
					.left {
						font-size: 21rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}
						
					.right {
						
						input {
							font-size: 21rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							width: 460rpx;
							text-indent: 20rpx;
						}
						
						.placeholder-class {
							color: #999999;
						}
						
						.uni-stat__select {
							width: 460rpx;

							/deep/.uni-select {
								border: none;
							}
						}
						
						.uni-date {
							width: 460rpx;
							
							/deep/.uni-date-editor--x {
								border: none;
							}
						}
					}
					
					&:nth-child(odd) {
						background: #F9F9F9;
					}
					
					&:last-child {
						border-bottom: none;
					}
				}
				
				.li:last-child {
					/deep/.uni-select__selector {
						top: initial;
					}
					
					/deep/.uni-popper__arrow {
						display: none;
					}
				}
			}
			
			.button {
				margin: 58rpx auto 0;
				padding: 0 95rpx 24rpx 95rpx;
				display: flex;
				
				button {
					width: 269rpx;
					height: 55rpx;
					line-height: 55rpx;
					background: #0552A9;
					border-radius: 10rpx;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
				
					&.determine {
						color: #fff;
					}
					
					&.cancellation {
						background: none;
						border: 1rpx solid #979797;
						color: #979797;
					}
				}
			}
		}
	}
	.navigator-check{
		position: absolute;
		width: 100rpx;
		height: 100rpx;
		z-index: 9;
		right: 0px;
		bottom: 0px;
		border-radius: 0rpx 0rpx 15rpx 0rpx;
	}
</style>
